<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>座位人员编辑-目的地运营集团数据管理平台</title>
<include file="Include:style" />
<style>
	.w50{ margin-left: 5px; width: 40px; text-align: center; }
	.checkbox-item span{ display: inline-block; line-height: 36px; }
	.checkbox-item span label input{ margin-top: 13px; }
	.checkbox-item span .size{ margin-top: 3px; }
	.project_add_search li{ cursor: pointer; }
	.project_add_search li:hover{ background: #f49900; color: #fff; }
</style>
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text">座位人员 > 座位人员编辑</div>
	</div>
	<div id="content">
		<form action="__APP__/Administration/seat_map_user_edit" method="post" enctype="multipart/form-data">
			<input type="hidden" name="action" value="edit">
			<input type="hidden" name="keyword" value="{$keyword}">
			<input type="hidden" name="id" value="{$detail['id']}">
			<div class="form-main">
				<div class="form-title">座位人员编辑</div>
				<div class="form-item">
					<div class="input-label">姓名</div>
					<div class="input-item" style="position:relative;">
						<div class="bclick">
							{$detail['users']}
						</div>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label" style="line-height:36px;"><span class="asterisk">*</span>IT类固资</div>
					<div class="input-item">
						<div class="checkbox-item it_check">
							<foreach name="it" item="vo">
								<span class="chesp mr10"><label class="checkbox-inline"><input type="checkbox" value="{$vo['id']}" autocomplete="off" name="it_goods[]" <if condition="$vo['check'] eq 1">checked</if>>{$vo['second_name']}</label>
								<if condition="$vo['check'] eq 1">
									<input type="text" class="form-control size w50" maxlength="2" autocomplete="off" name="it_goods_sum[]" value="{$vo['sum']}"></span>
								<else/>
									<input type="text" class="form-control size hide w50" maxlength="2" autocomplete="off" name="it_goods_sum[]"></span>
								</if>
							</foreach>
							<span class="error-item"></span>
						</div>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label" style="line-height:36px;"><span class="asterisk">*</span>行政固资</div>
					<div class="input-item">
						<div class="checkbox-item xz_check">
							<foreach name="xz" item="vo">
								<span class="chesp mr10"><label class="checkbox-inline"><input type="checkbox" value="{$vo['id']}" autocomplete="off" name="xz_goods[]" <if condition="$vo['check'] eq 1">checked</if>>{$vo['second_name']}</label>
								<if condition="$vo['check'] eq 1">
									<input type="text" class="form-control size w50" maxlength="2" autocomplete="off" name="xz_goods_sum[]" value="{$vo['sum']}"></span>
								<else/>
									<input type="text" class="form-control size hide w50" maxlength="2" autocomplete="off" name="xz_goods_sum[]"></span>
								</if>
							</foreach>
							<span class="error-item"></span>
						</div>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label">其它</div>
					<div class="input-item">
						<input type="text" name="other_goods" class="form-control required-text w150" autocomplete="off" value="{$detail['other_goods']}">
					</div>
				</div>
				<div class="form-item">
					<div class="input-label">备注</div>
					<div class="input-item">
						<textarea name="remark" class="form-control w500 h150" autocomplete="off">{$detail['remark']}</textarea>
					</div>
				</div>
				<div class="form-btn-item"><button class="btn submit" type="submit">生成</button><button class="btn btn-default goback" type="button">返回</button></div>
			</div>
		</form>
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript">
	$(function() {
		//固资
		$('body').on('click','.checkbox-inline',function(){
			if($(this).find('input').is(":checked")){
				$(this).next('.size').show();
			}else{
				$(this).next('.size').val('').hide();
			}
			$('.Text_c1').hide();
		})
		//姓名
		$(".project_add_inp").bind('propertychange input', function () {
			var val = $(this).val(),
				_this = $(this);
			_this.addClass('active');
			_this.siblings('.project_add_search').find('ul').show();
			var mid = "{$detail['id']}",
				p = '';
			for(var i=0;i<$('.name2 p').length;i++){
				var text = $('.name2 p').eq(i).text();
				p+= ""+text+"";
				if(i<$('.name2 p').length-1){
					p+= ",";
				}
			}
			$.ajax({
				type:"POST",
				asnyc:false,
				dataType:"json",
				data:{"val":val,"id":mid,"user":p,"action":"find_user"},
				url:"__APP__/Administration/seat_map_ajax",
				success:function(data){
					if(data){
						var html='';
						for(var i=0;i<data.length;i++){
							html+= "<li class='li'>"+data[i].username+"</li>"
						}
						_this.siblings('.project_add_search').find('ul').html(html);
					}else{
						_this.siblings('.project_add_search').find('ul').html("<li>没有匹配项目</li>");
					}
				}
			});
		})
		$('body').on('click','.project_add_search .li',function(){
			var text = $(this).text();
			$(this).parents('.project_add_search').siblings('.project_add_inp').val(text);
			$(this).parents('.project_add_search').hide();
		})
		$("body").click(function(n) {
			var t = $(".bclick");
			t.is(n.target) || t.has(n.target).length !== 0 || (t.find('.project_add_inp').removeClass("active"), t.find(".project_add_search").hide())
		})
		$(".project_add_inp").focus(function(){
			$(this).siblings('.project_add_search').show();
			if($(this).val()!=''){
				$(this).addClass('active');
			}
			$('.project_add_search ul').show();
			var mid = "{$detail['id']}",
				val = $(this).val(),
				_this = $(this),
				p = '';
			for(var i=0;i<$('.name2 p').length;i++){
				var text = $('.name2 p').eq(i).text();
				p+= ""+text+"";
				if(i<$('.name2 p').length-1){
					p+= ",";
				}
			}
			$.ajax({
				type:"POST",
				asnyc:false,
				dataType:"json",
				data:{"val":val,"id":mid,"user":p,"action":"find_user"},
				url:"__APP__/Administration/seat_map_ajax",
				success:function(data){
					if(data){
						var html='';
						for(var i=0;i<data.length;i++){
							html+= "<li class='li'>"+data[i].username+"</li>"
						}
						_this.siblings('.project_add_search').find('ul').html(html);
					}else{
						_this.siblings('.project_add_search').find('ul').html("<li>没有匹配项目</li>");
					}
				}
			});
		})

		//提交
		$('.submit').click(function(){
			var tag = false;
			
			var val = $("[name='nums1']").val();
			if(val=="" || /^\s+$/.test(val)){
				$("[name='nums1']").nextAll('.error-item').show();
				tag = true;
			}
			
			if($('.it_check').find("input:checked").length==0){
				$('.it_check .error-item').show().html('请至少勾选一项IT固资');
				tag = true;
			}
			$('.it_check .chesp').each(function(){
				if($(this).find('label input').is(":checked")){
					if($(this).find('.size').val()==''){
						$('.it_check .error-item').show().html('请填写选中固资数量');
						tag = true;
					}
				}
			})
			if($('.xz_check').find("input:checked").length==0){
				$('.xz_check .error-item').show().html('请至少勾选一项行政固资');
				tag = true;
			}
			$('.xz_check .chesp').each(function(){
				if($(this).find('label input').is(":checked")){
					if($(this).find('.size').val()==''){
						$('.xz_check .error-item').show().html('请填写选中固资数量');
						tag = true;
					}
				}
			})
			if(tag){
				return false;
			}
		})
		$('label').click(function(){
			$(this).parents('.checkbox-item').find('.error-item').hide();
		})
		$('body').on('focus','.size',function(){
			$(this).parents('.checkbox-item').find('.error-item').hide();
		})
		$('.required-text').focus(function(){
			$(this).nextAll('.error-item').hide();
		})
	});
</script>
</body>
</html>